package com.pvdnc.tapkit.chat.ui;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.pvdnc.tapkit.chat.R;

import jsc.kit.adapter.SimpleAdapter4;

public class ChatAdapter extends SimpleAdapter4<BubbleEntity,String> {
    @Override
    protected void onBindDataViewHolder(@NonNull BaseViewHolder holder, int position, BubbleEntity dataBean) {
        super.onBindDataViewHolder(holder, position, dataBean);
        //左侧
        LinearLayout lyLeft=holder.findViewById(R.id.lyLeft);
        TextView lblLeftMsg=holder.findViewById(R.id.lblLeftMsg);
        //右侧
        LinearLayout lyRight=holder.findViewById(R.id.lyRight);
        TextView lblRightMsg=holder.findViewById(R.id.lblRightMsg);
        switch (dataBean.mDirection){
            case BubbleEntity.DIRECTION_LEFT:{
                lyLeft.setVisibility(View.VISIBLE);
                lyRight.setVisibility(View.INVISIBLE);
                lblLeftMsg.setText(dataBean.mContent);
                break;
            }
            case BubbleEntity.DIRECTION_RIGTH:{
                lyLeft.setVisibility(View.INVISIBLE);
                lyRight.setVisibility(View.VISIBLE);
                lblRightMsg.setText(dataBean.mContent);
                break;
            }
        }
    }
}
